package com.young.msg.model;

import com.young.common.util.StringUtils;

/**
 * 邮件发送命令对象
 *
 * @author wangjy
 * @date 2021/10/30 00:52:52
 */
public class MailSendCommand {

    /**
     * 发送器标识
     */
    private String senderCode;
    /**
     * 收件人邮箱地址
     */
    private String receiver;
    /**
     * 标题
     */
    private String title;
    /**
     * 邮件内容
     */
    private String content;

    /**
     * 构造邮件发送命令对象
     *
     * @param senderCode 发送器标识
     * @param receiver   收件人邮箱
     * @param title      标题
     * @param content    内容
     * @return
     */
    public static MailSendCommand build(String senderCode, String receiver, String title, String content) {
        MailSendCommand command = new MailSendCommand();
        command.setSenderCode(senderCode);
        command.setReceiver(receiver);
        command.setTitle(title);
        command.setContent(content);
        return command;
    }

    /**
     * 构造邮件发送命令对象
     *
     * @param receiver 收件人邮箱
     * @param title    标题
     * @param content  内容
     * @return
     */
    public static MailSendCommand build(String receiver, String title, String content) {
        MailSendCommand command = new MailSendCommand();
        command.setReceiver(receiver);
        command.setTitle(title);
        command.setContent(content);
        return command;
    }

    /**
     * 校验
     *
     * @return
     */
    public boolean check() {
        return StringUtils.isNotBlank(receiver) && StringUtils.isNotBlank(title) && StringUtils.isNotBlank(content);
    }

    public String getReceiver() {
        return receiver;
    }

    public void setReceiver(String receiver) {
        this.receiver = receiver;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getSenderCode() {
        return senderCode;
    }

    public void setSenderCode(String senderCode) {
        this.senderCode = senderCode;
    }
}
